#ifndef CONTAINSVALIDATOR_H
#define CONTAINSVALIDATOR_H

#include "stringvalidator.h"
#include "pretreatmenthandler.h"

class ContainsValidator : public StringValidator
{
public:
    ContainsValidator();
    ContainsValidator(const QString& substring, const QString& errorMsg = "Substring not found")
        : m_substring(substring), m_errorMsg(errorMsg) {}

    ValidationResult validate(const QString& input,
                              const std::vector<ValidationOption>& options = {}) const override {
        QString processed = PretreatmentHandler::preprocess(input, options); //先进性预处理，返回一个字符串

        if (processed.contains(m_substring, PretreatmentHandler::getCaseSensitivity(options))) {
            return ValidationResult(true);
        }
        return ValidationResult(false, m_errorMsg.arg(m_substring));
    }

private:
    QString m_substring;
    QString m_errorMsg;
};

#endif // CONTAINSVALIDATOR_H
